package com.dingtalk.controller;

import com.alibaba.fastjson.JSONObject;
import com.dingtalk.service.CommentService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * @Title: Controller
 * @Description: TODO
 * @Create 2022/10/8 11:21
 * @Author: Wang.Tonglin
 * @Contact: wang.tonglin@trs.com.cn
 * @Company: 成都拓尔思信息技术有限公司
 * @Department: 中台（Middle-End）
 */
@RestController
@RequestMapping("/ding")
public class Controller {
    @Resource
    private CommentService service;

    @RequestMapping("/comment")
    public void sendMessage(HttpServletRequest request) throws IOException {
        service.sendMessage(request);
    }

    @RequestMapping("/test")
    public void get(HttpServletRequest request) throws IOException {
        JSONObject data = service.getData(request);
        System.out.println(data);
        JSONObject comment = null;
        try {
             comment = data.getJSONObject("comment");
        }catch (Exception e){
            System.out.println("这个不是comment！");
        }

        System.out.println(comment);

    }

    @RequestMapping("/robot")
    public void at(HttpServletRequest request) throws IOException {
        service.sendComment(request);
    }
}
